<template>
  <div class="wrap">
    <el-menu
      default-active="2"
      class="el-menu-vertical-demo top"
      @open="handleOpen"
      @close="handleClose">
      <el-submenu index="1">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>热门文章</span>
        </template>

       <el-menu-item-group title="分组1">
          <el-submenu class="ddd" :index="'1-'+item.id" v-for="item in blogs">
            <template slot="title">{{item.title}}</template>
            <el-menu-item  :index="'11-'+item.id" >id:{{item.id}}</el-menu-item>
          </el-submenu>
        </el-menu-item-group>

 
      </el-submenu>



      <el-menu-item index="2">
        <i class="el-icon-menu"></i>
        <span slot="title">最近更新</span>
      </el-menu-item>
      <el-menu-item index="3" disabled>
        <i class="el-icon-document"></i>
        <span slot="title">文章归档</span>
      </el-menu-item>
      <el-menu-item index="4">
        <i class="el-icon-setting"></i>
        <span slot="title">分类目录</span>
      </el-menu-item>
    </el-menu>
  </div>
</template>

<script>
export default {
    name: "nav.vue",
    data () {
        return {
            value: new Date(),
            blogs: {},
            currentPage: 1,
            total:  0,
            pageSize: 5
        }
    },
    methods: {
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      },
      nav(currentPage) {
        const _this = this
         
        this.$axios.get("/blogs?currentPage=" + currentPage).then(res => {
          _this.blogs = res.data.data.records
          _this.currentPage = res.data.data.current
          _this.total = res.data.data.total
          _this.pageSize = res.data.data.size
        })
       }
    } ,



    mounted() {
      this.nav(1)
    }
  }
</script>

<style scoped>
   .top {
     margin-top: 100px;
   }
   .ddd {
     overflow: hidden
   }
</style>